<template>
  <div class="app-container ">
    <el-form ref="form" size="small" :model="form" :rules="rules" label-width="180px" style="background: rgb(255, 255, 255);width: 550px;height: 600px;margin: 0px 0px 0px 500px;border-radius: 10px;">
      <el-tabs v-model="activeName">
        <el-tab-pane style="padding-top:10px" label="" name="送积分设置">

          <el-row>
            <el-col :span="24">
              <el-form-item label="开启统一送积分设置" prop="status">
                <el-switch v-model="form.status" active-value="1" inactive-value="0" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="邀请新用户奖励积分">
                <el-input
                  v-model="form.addmember"
                  controls-position="right"
                  style="width:100px;"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder=""
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="邀请分销达人奖励积分">
                <el-input
                  v-model="form.addagent"
                  controls-position="right"
                  style="width:100px;"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder=""
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="邀请师傅入驻奖励积分">
                <el-input
                  v-model="form.addtechnical"
                  controls-position="right"
                  style="width:100px;"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder=""
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="邀请商户入驻奖励积分">
                <el-input
                  v-model="form.addstore"
                  controls-position="right"
                  style="width:100px;"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder=""
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      <el-form-item>
        <el-button size="small" type="primary" @click="submit">保存设置</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>
<script>
export default {
  name: 'Configpoints',
  components: {
  },
  data() {
    return {
      form: {
        addcustomer: '',
        adddongtai: '',
        upjieduan: '',
        deal: '',
        status: 0
      },
      loading: false,
      activeName: '送积分设置',
      rules: {
      }
    }
  },
  mounted() {
    this.$api.post('/config/getInfo', { mo: 'points' }).then(res => {
      this.form = JSON.stringify(res.data) == '[]' ? {} : res.data
      this.setDefaultVal('keyword')
    })
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$api.post('/config/update', this.form).then(res => {
            this.$message({ message: '操作成功', type: 'success' })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    },
    setDefaultVal(key) {
      if (this.form[key] == null || this.form[key] == '') {
        this.form[key] = []
      }
    }
  }
}
</script>


<style scoped>
::v-deep .el-input__inner {
    -webkit-appearance: none;
    background-color: #FFFFFF;
    background-image: none;
    border-radius: 50px;
    border: 1px solid #DCDFE6;
    box-sizing: border-box;
    color: #606266;
    display: inline-block;
    font-size: inherit;
    height: 30px;
    line-height: 40px;
    outline: none;
    padding: 0 15px;
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    width: 100%;
}

::v-deep  .el-tabs__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0px;
    background-color: #ffffff;
    z-index: 1;
}

.el-form-item--small.el-form-item {
    margin: 0px 0px 0px 120px;
    margin-bottom: 22px;
}

::v-deep .el-tabs__header {
    padding-left: 20px;
    height: 0px;
}

</style>